//
//  stack_demo.hpp
//  cpp_algorithm
//
//  Created by 李贺 on 2022/1/13.
//

#ifndef stack_demo_hpp
#define stack_demo_hpp

#include <stdio.h>
#include <vector>
#include <iostream>
#include <string>
#include <unordered_map>
#include <stack>
using namespace std;

namespace stack_demo_space {
class Solution{

public:
    
    bool is_valid(string s) {
        
        stack<int> st;
        bool come = false;
        for (int i = 0; i < s.size(); ++i) {
            
            if (s[i] == '(') {
                st.push(')');
            } else if (s[i] == '{') {
                st.push('}');
            } else if (s[i] == '[') {
                st.push(']');
            } else {
                come = true;
                st.pop();
            }
        }
        
        return st.empty() && come;
    }
    
};
}

#endif /* stack_demo_hpp */
